import React from 'react';
import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom';
import { AuthProvider } from './src/context/AuthContext';
import { ConfigProvider } from './src/context/ConfigContext';
import { LanguageProvider } from './src/context/LanguageContext';
import MainLayout from './src/layouts/MainLayout';
import HomeView from './src/views/HomeView';
import AboutView from './src/views/AboutView';
import ProductsView from './src/views/ProductsView';
import ContactView from './src/views/ContactView';
import AdminView from './src/views/AdminView';
import LoginView from './src/views/LoginView';
import PrivateRoute from './src/routes/PrivateRoute';

const App: React.FC = () => (
  <AuthProvider>
    <ConfigProvider>
      <LanguageProvider>
        <BrowserRouter>
          <Routes>
            <Route path="/" element={<MainLayout />}>
              <Route index element={<HomeView />} />
              <Route path="about" element={<AboutView />} />
              <Route path="products" element={<ProductsView />} />
              <Route path="contact" element={<ContactView />} />
              <Route element={<PrivateRoute />}>
                <Route path="admin" element={<AdminView />} />
              </Route>
            </Route>
            <Route path="/login" element={<LoginView />} />
            <Route path="*" element={<Navigate to="/" replace />} />
          </Routes>
        </BrowserRouter>
      </LanguageProvider>
    </ConfigProvider>
  </AuthProvider>
);

export default App;
